package tiny.soft.com.core.config.security.service;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;

import java.util.Collection;

/**
 * tiny.soft.com.core.config.security.service
 *
 * @Auther: 宋晓虎
 * @Date: 2019/12/25 00:38
 * @Description:
 */
public class UserDetailImpl implements UserDetails {
    private final String username;
    private final String password;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }
    //用User构造
    public UserDetailImpl(User user) {
        this.username = user.getUsername();
        this.password = user.getPassword();
    }
    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}